<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="|#{customer.systemTitle}-用户权限-组织机构维度|">图灵谷</title>
<div th:replace="fragments/head_admin">head</div>
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		<div th:replace="fragments/nav_admin">导航栏</div>
		<div th:replace="fragments/menu_admin::menu(parent=site,child=friendlinkType)">菜单栏</div>
		<div class="layui-body">
			<div class="layui-main">
				<!--/***** 面包屑 *****/-->
				<div class="layui-elem-quote" style="margin-top: 10px;">
					<span class="layui-breadcrumb"> <a><cite>站点管理</cite></a> <a href="#">友情链接类型</a> <a><cite>列表</cite></a>
					</span>
				</div>
				<blockquote class="layui-elem-quote layui-quote-nm">
					<div class="layui-inline">
						<div class="layui-input-inline">
							<a th:href="@{/admin/m/ext/friendlinkType/add.gsp}" class="layui-btn"><i class="layui-icon">&#xe608;</i> 新增</a>
						</div>
					</div>
				</blockquote>
				<table cellspacing="0" width="100%" class="layui-table" lay-even="" lay-skin="row">
					<thead>
						<tr>
							<th width="40">#</th>
							<th width="40">状态</th>
							<th>类型名称</th>
							<th>类型编码</th>
							<th>描述</th>
							<th>排序</th>
							<th width="90" class="text-center">操作</th>
						</tr>
					</thead>
					<tbody>
						<tr th:if="${friendlinkTypeList.records == null or friendlinkTypeList.records.size() == 0}">
							<td colspan="7" style="text-align: center;">暂时没有数据</td>
						</tr>
						<tr th:each="item,itemStat:${friendlinkTypeList.records}">
							<td th:text="${friendlinkTypeList.pageSize*(friendlinkTypeList.page-1)+itemStat.index+1}" style="text-align: center;"></td>
							<td class="layui-form"><input lay-filter="filter" th:id="${item.id}" lay-skin="switch" type="checkbox" th:attr="checked=${item.enabled ==1}"></td>
							<td th:text="${item.typeName}" style="text-align: center;"></td>
							<td th:text="${item.codeNum}" style="text-align: center;"></td>
							<td th:text="${item.description}" style="text-align: center;"></td>
							<td th:text="${item.sortOrder}" style="text-align: center;"></td>
							<td><a th:href="|@{/admin/m/ext/friendlinkType/edit_}${item.id}.gsp|" class="layui-btn layui-btn-small"> <i class="layui-icon"></i></a> <a th:onclick="|del('${item.id}')|" class="layui-btn layui-btn-normal layui-btn-small"> <i class="layui-icon"></i></a></td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div th:replace="fragments/footer_admin">底部</div>
	</div>
</body>
<div th:replace="fragments/import_js_admin">引入js</div>
</html>
<script th:inline="javascript">
    /*<![CDATA[*/
var $ = layui.jquery;
    var form = layui.form();
    var enableUrl = /*[[@{/admin/m/ext/friendlinkType/enable_{id}.gsp}]]*/;
    var disableUrl = /*[[@{/admin/m/ext/friendlinkType/disable_{id}.gsp}]]*/;
    form.on('switch(filter)', function(data){
        var id = data.elem.id;
        if(!$("#" + data.elem.id).prop("checked")){  
            layer.confirm('您确定要停用吗？', {
                btn: ['确定','取消'] 
            }, function(){
             //停用
             var url = disableUrl.replace("{id}",data.elem.id);
             $.post(url,{'id':data.elem.id},function(){    
                 $("#" + data.elem.id).prop("checked", false);
                 $("#" + data.elem.id).next().removeClass("layui-form-onswitch");
             });  
             layer.msg('停用成功！', {icon: 1});
             setTimeout(function(){window.location.reload();},1000);
            }, function(){
                $("#" + data.elem.id).prop("checked", true);
                $("#" + data.elem.id).next().addClass("layui-form-onswitch");
            });
        }else if($("#" + data.elem.id).prop("checked")){   
            layer.confirm('您确定要启用吗？', {
                btn: ['确定','取消'] 
            }, function(){
          //启用
          var url = enableUrl.replace("{id}",data.elem.id);
          $.post(url,{'id':data.elem.id},function(){
              $("#" + data.elem.id).prop("checked", true);
              $("#" + data.elem.id).next().addClass("layui-form-onswitch");
          });
          layer.msg('启用成功！', {icon: 1});
          setTimeout(function(){window.location.reload();},1000);
          }, function(){
              $("#" + data.elem.id).prop("checked", false);
              $("#" + data.elem.id).next().removeClass("layui-form-onswitch");
          });
        }    
    });  
    
    var deleteUrl = /*[[@{/admin/m/ext/friendlinkType/delete_{id}.gsp}]]*/;
    function del(id){
        tg_deleteItem(deleteUrl.replace('{id}',id), function(){
            location.reload();
        });       
    }
    /*]]>*/
</script>
